import { SET_HOTEL_DATE, SET_HOTEL_CITY } from '../constants/hotel'
import Moment from '../utils/moment'

const INITIAL_STATE = {
  checkInDate: Moment(new Date()).format('YYYY-MM-DD'),
  checkOutDate: Moment(new Date()).add(1, 'day').format('YYYY-MM-DD'),
  city: ''
}

export default function counter (state = INITIAL_STATE, action) {
  switch (action.type) {
     case SET_HOTEL_DATE:
       return {
         ...state,
         checkInDate: action.payload.checkInDate,
         checkOutDate: action.payload.checkOutDate
       }
     case SET_HOTEL_CITY:
       return {
         ...state,
         city: action.payload.city
       }
     default:
       return state
  }
}
